package com.ityuwen.mengyagushi.account.api;

import com.ityuwen.mengyagushi.account.service.RechargeInfoService;
import com.ityuwen.mengyagushi.common.login.GuiGuLogin;
import com.ityuwen.mengyagushi.common.result.Result;
import com.ityuwen.mengyagushi.model.account.RechargeInfo;
import com.ityuwen.mengyagushi.vo.account.RechargeInfoVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "充值管理")
@RestController
@RequestMapping("api/account/rechargeInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class RechargeInfoApiController {

	@Autowired
	private RechargeInfoService rechargeInfoService;


	@GuiGuLogin
	@PostMapping("submitRecharge")
	public Result<Map<String, Object>> submitRecharge(@RequestBody RechargeInfoVo rechargeInfoVo){
		Map<String, Object> map = this.rechargeInfoService.submitRecharge(rechargeInfoVo);
		return Result.ok(map);
	}

	@GetMapping("getRechargeInfo/{orderNo}")
	public Result<RechargeInfo> getRechargeInfo(@PathVariable("orderNo")String orderNo){
		RechargeInfo rechargeInfo = this.rechargeInfoService.getOne(new LambdaQueryWrapper<RechargeInfo>().eq(RechargeInfo::getOrderNo, orderNo));
		return Result.ok(rechargeInfo);
	}

}

